package com.kun.coupon.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kun.api.ICouponService;
import com.kun.common.constant.ShopCode;
import com.kun.coupon.mapper.TradeCouponMapper;
import com.kun.pojo.domain.TradeCoupon;
import com.kun.pojo.entity.Result;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 优惠券
 */
@Service
@DubboService
public class ICouponServiceImpl extends ServiceImpl<TradeCouponMapper, TradeCoupon> implements ICouponService {

    /**
     * 根据ID查找优惠券
     */
    @Override
    public TradeCoupon findOne(@NotNull(message = "请求的参数非法") Long couponId) {
        return getById(couponId);
    }

    /**
     * 更新优惠券状态
     */
    @Override
    public Result updateCouponStatus(@Valid TradeCoupon tradeCoupon) {
        updateById(tradeCoupon);
        return Result.success(ShopCode.SHOP_SUCCESS.getMessage());
    }
}




